local PartnerSkillIconRender = app.mvc.createRenderClass(...)

--data =
function PartnerSkillIconRender.create(node)
    local sprite = PartnerSkillIconRender.extend(node or cc.CSLoader:createNode(Res.PartnerSkillIcon))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init()
    return sprite
end


function PartnerSkillIconRender:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self:refresh()
    
    self._ui["Panel"]:addClickEventListener(function(sender)
        self:showTips(sender)
    end)
end

function PartnerSkillIconRender:showTips(sender)
    local data = self._data
    if not data then
        return
    end
    local params = {}
    params.tipsType = Enums.TipsType.classSkill
    params.itemId = data:getClassSkillId()
    local otherParams = {}
    local size = sender:getContentSize()
    local pos = sender:convertToWorldSpace(cc.p(0,0))
    otherParams.tipPos = cc.p(pos.x - size.width/2, pos.y + size.height)
    EM:notify(ViewEvent.Partner_ShowTips, params, otherParams)
end

function PartnerSkillIconRender:refresh()
    if not self._data then
        return
    end
    
    local data = self._data  
    self._ui["Panel/icon"]:loadTexture(data:getIcon())
end



return PartnerSkillIconRender